<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta content="webkit" name="renderer" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta content="no-cache" http-equiv="Pragma" />
  <meta http-equiv="Expires" content="0" />
  <meta content="width=device-width, initial-scale=1, user-scalable=1" name="viewport" />
  <title>首页-ERP</title>
  <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
  <script src="js/jquery/jquery-1.12.4.min.js"></script>
  <!--[if lt IE 9]><script src="js/common/h5fix.min.js"></script><![endif]-->
  <link rel="stylesheet" href="css/fonts/font-icons.min.css">
  <link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="js/adminlte/css/AdminLTE.min.css">
  <link rel="stylesheet" href="css/jsherp.css">
  <link rel="stylesheet" href="js/adminlte/css/skins/skin-blue-light2.css">
  <script src="js/jquery/jquery.cookie.js"></script>
  <script src="js/jquery-i18n/index.js"></script>
  <script>
    myi18nInit('/ejs/home.ejs', [
      "js/layer/3.1/layer.js",
      "js/common/jsherp.js",
      "js/common/common.js",
      "js/common/i18n/jsherp_{lang}.js",
      "js/jquery/jquery-ui-sortable-1.12.1.min.js",
      "js/highcharts/highcharts.js",
      "js/highcharts/exporting.js",
      "js/highcharts/highcharts-{lang}.js",
    ], function () {
      if ($('#switchSkin').length > 0) {
        $('#switchSkin i').addClass('jump5');
        setTimeout(function () {
          $('.main-sidebar [title="' + window.i18n.RoleManagement + '"]').append('<span class="pull-right-container">'
            + '<small class="label pull-right bg-red jump">hot</small></span>');
        }, 2000);
      }
      //
      $(window).resize(function () {
        var footerHeight = $('.main-footer').outerHeight() || 0;
        var windowHeight = $(window).height();
        $('.content').css('min-height', windowHeight - footerHeight)
      }).resize();
      $('.ui-sortable').sortable({
        placeholder: 'sort-highlight',
        connectWith: '.ui-sortable',
        handle: '.box-header, .nav-tabs',
        forcePlaceholderSize: true, zIndex: 999999
      }).find('.box-header, .nav-tabs').css('cursor', 'move');

      $(function () {
        $.ajax({
          type: "get",
          url: "/depotHead/getBuyAndSaleStatistics",
          dataType: "json",
          success: function (res) {
            if (res && res.code === 200) {
              if (res.data) {
                $("#todaySale").text((res.data.todaySale).toFixed(2));
                $("#thisMonthSale").text((res.data.thisMonthSale).toFixed(2));
                $("#thisMonthBuy").text((res.data.thisMonthBuy).toFixed(2));
              }
            }
          },
          error: function (res) {

          }
        });
      });

      $(function () {
        $.ajax({
          type: "get",
          url: "/account/getStatistics",
          dataType: "json",
          success: function (res) {
            if (res && res.code === 200) {
              if (res.data) {
                $("#thisMonthAmount").text((res.data.allMonthAmount - 0).toFixed(2));
              }
            }
          },
          error: function (res) {

          }
        });
      });

      function getChartObj(titleName, categories, seriesData) {
        var chartObj = {
          chart: {
            type: 'spline'
          },
          title: {
            text: titleName
          },
          xAxis: {
            categories: categories
          },
          yAxis: {
            title: {
              text: window.i18n.Amount
            }
          },
          series: [{
            name: titleName,
            data: seriesData
          }]
        }
        return chartObj;
      }
      $(function () {
        $.ajax({
          type: "get",
          url: "/depotItem/buyOrSalePrice",
          dataType: "json",
          success: function (res) {
            if (res && res.code === 200) {
              var data = res.data;
              Highcharts.chart('buyIn', getChartObj(window.i18n.PurchasingDataInTheLast6Months, res.data.monthList, res.data.buyPriceList));
              Highcharts.chart('saleOut', getChartObj(window.i18n.SalesDataOfTheLastSixMonths, res.data.monthList, res.data.salePriceList));
            }
          },
          error: function (res) {

          }
        });
      });

    })
  </script>
</head>

<body class="hold-transition ">
</body>